//
//  MyPointsListCell.m
//  BaseProject
//
//  Created by 王盼盼 on 2024/11/7.
//  Copyright © 2024 wangpanpan. All rights reserved.
//

#import "MyPointsListCell.h"
#import "YunOrderListModel.h"
#import "CommonRecommandUserModel.h"
@interface MyPointsListCell ()
@property(nonatomic, strong) UILabel *firstLabel;
@property(nonatomic, strong) UILabel *secondLabel;
@property(nonatomic, strong) UILabel *thirdLabel;
@end

@implementation MyPointsListCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = UIColor.whiteColor;
        self.backgroundColor = UIColor.whiteColor;
        [self addSubview:self.firstLabel];
        [self addSubview:self.secondLabel];
        [self addSubview:self.thirdLabel];
        [self addSubview:self.lineView];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.mas_equalTo(0);
            make.height.mas_equalTo(0.5);
        }];
    }
    return self;
}
- (void)setData:(YunOrderListModel *)data {
    _data = data;
    self.firstLabel.text = data.orderId;
    self.secondLabel.text = data.createTime;
    self.thirdLabel.text = [NSString stringWithFormat:@"+%@",[Utilities removeNumberZeroWithDouble:data.points]];
    
    self.firstLabel.frame = CGRectMake(16, 13, kScreenWidth * 0.4 - 20, 0);
    self.secondLabel.frame = CGRectMake(kScreenWidth * 0.4, 13, kScreenWidth * 0.4 - 5, 0);
    self.thirdLabel.frame = CGRectMake(kScreenWidth * 0.8, 13, kScreenWidth * 0.2 - 5, 0);
    [self.firstLabel sizeToFit];
    [self.secondLabel sizeToFit];
    [self.thirdLabel sizeToFit];
    data.cellHeight = MAX(self.firstLabel.bottom, self.secondLabel.bottom);
    data.cellHeight = MAX(data.cellHeight, self.thirdLabel.bottom);
    data.cellHeight = data.cellHeight + 13;
}
- (void)setRecData:(CommonRecommandUserModel *)data {
    _recData = data;
    if (data.isBuTieMingXi) {
        self.firstLabel.text = data.sellerName;
        self.secondLabel.text = data.createTime;
        self.thirdLabel.text = [NSString stringWithFormat:@"+%@",[Utilities removeNumberZeroWithDouble:data.recommerFree]];
    } else {
        self.firstLabel.text = data.name;
        self.secondLabel.text = data.createTime;
        self.thirdLabel.text = [NSString stringWithFormat:@"￥%@",[Utilities removeNumberZeroWithDouble:data.availableAmount]];
    }
    
    self.firstLabel.frame = CGRectMake(16, 13, kScreenWidth * 0.3 - 30, 0);
    self.secondLabel.frame = CGRectMake(kScreenWidth * 0.3, 13, kScreenWidth * 0.45 - 5, 0);
    self.thirdLabel.frame = CGRectMake(kScreenWidth * 0.75, 13, kScreenWidth * 0.25 - 5, 0);
    
    [self.firstLabel sizeToFit];
    [self.secondLabel sizeToFit];
    [self.thirdLabel sizeToFit];
    data.cellHeight = MAX(self.firstLabel.bottom, self.secondLabel.bottom);
    data.cellHeight = MAX(data.cellHeight, self.thirdLabel.bottom);
    data.cellHeight = data.cellHeight + 13;
}
#pragma mark - lazy
- (UILabel *)firstLabel {
    if (!_firstLabel) {
        UILabel *lab = [[UILabel alloc]init];
        lab.font = kFontRegular(14);
        lab.textColor = rgba(47, 47, 52, 1);
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 0;
        _firstLabel = lab;
    }
    return _firstLabel;
}
- (UILabel *)secondLabel {
    if (!_secondLabel) {
        UILabel *lab = [[UILabel alloc]init];
        lab.font = kFontRegular(14);
        lab.textColor = rgba(47, 47, 52, 1);
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 0;
        _secondLabel = lab;
    }
    return _secondLabel;
}
- (UILabel *)thirdLabel {
    if (!_thirdLabel) {
        UILabel *lab = [[UILabel alloc]init];
        lab.font = kFontRegular(14);
        lab.textColor = rgba(47, 47, 52, 1);
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 0;
        _thirdLabel = lab;
    }
    return _thirdLabel;
}
- (UIView *)lineView {
    if (!_lineView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = rgba(229, 231, 236, 1);
        _lineView = view;
    }
    return _lineView;
}
@end
